package org.example.suanfa;

import java.util.Arrays;

public class 冒泡排序 {
    public static void main(String[] args) {
     int[] arrs=new int[]{5,8,7,6,9,2,3,1,4};
        System.out.println(Arrays.toString(bubbleSort(arrs)));
    }
    public static int[] bubbleSort(int[] arrss){
        int n=arrss.length;
        for (int i=0;i<n-1;i++){
            for (int j=0;j<n-i-1;j++){
                if (arrss[j]>arrss[j+1]){
                    int tepm=arrss[j];
                    arrss[j]=arrss[j+1];
                    arrss[j+1]=tepm;
                }
            }
        }
        return arrss;

    }
}
